package com.escope.casemanager.controller;

import com.escope.casemanager.model.CaseExample;
import com.escope.casemanager.model.HttpResult;
import com.escope.casemanager.model.PageModel;
import com.escope.casemanager.service.CaseExampleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 案例管理接口
 * 2024/3/15
 */
@RestController
@RequestMapping("case")
@CrossOrigin
@Api(value = "案例管理接口", tags = {"案例管理接口"})
public class CaseExampleController {
    @Autowired
    private CaseExampleService caseExampleService;

    @GetMapping(value = "/findByPage")
    @ApiOperation("查询案例分页列表")
    public HttpResult findByPage(PageModel page,
                                 @RequestParam Map<String, Object> map) {
        return caseExampleService.findByPage(page, map);
    }

    @GetMapping(value = "/findById")
    @ApiOperation("根据ID查询案例信息")
    public HttpResult findById(Long id) {
        return caseExampleService.findById(id);
    }

    @PostMapping(value = "/save")
    @ApiOperation("创建或修改案例信息")
    public HttpResult save(CaseExample example) {
        return caseExampleService.saveOrUpdate(example);
    }

    @PostMapping(value = "/delete")
    @ApiOperation("删除案例信息")
    public HttpResult delete(Long id) {
        return caseExampleService.delete(id);
    }


}
